package com.woniuxy.microretailserver.mapper;

import com.woniuxy.microretailserver.bean.GoodsPayBean;
import com.woniuxy.microretailserver.bean.ReturnPayInfoBean;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author chenhu
 * 购买订单支付持久层接口
 */
@Mapper
public interface GoodsPayMapper {

    /**
     * 新增购买订单支付
     * @param goodsPayBean
     * @return
     */
    @Insert("insert into t_pay_info" +
           "(payment,payment_amount,payment_time,payment_status,payment_num,remark_info)" +
           "values(#{y.payment},#{y.paymentAmount},now(),#{y.paymentStatus},#{y.paymentNum},#{y.remarkInfo})")
    int saveGoodsPay(@Param("y") GoodsPayBean goodsPayBean);

    /**
     * 新增退货订单支付
     * @param returnPayInfoBean
     * @return
     */
    @Insert("insert into t_return_pay_info" +
            "(payment,payment_amount,payment_time,payment_status,payment_num,remark_info)" +
            "values(#{y.payment},#{y.paymentAmount},now(),#{y.paymentStatus},#{y.paymentNum},#{y.remarkInfo})")
    int saveGoodsReturnPay(@Param("y") ReturnPayInfoBean returnPayInfoBean);

    /**
     * 根据订单id查询订单支付信息
     * @param id
     * @return
     */
    @Select("select * from t_pay_info where id=#{id}")
    GoodsPayBean findByIdPay(@Param("id") long id);

    /**
     * 根据订单id查询退货支付信息
     * @param id
     * @return
     */
    @Select("select * from t_return_pay_info where id=#{id}")
    ReturnPayInfoBean findByIdReturnPay(@Param("id") long id);

    /**
     * 查询支付订单全部信息
     * @param goodsPayBean
     * @return
     */
    List<GoodsPayBean> findPay(@Param("g") GoodsPayBean goodsPayBean);
}
